module.exports = {
    $is_X() {
        const res = uni.getSystemInfoSync();
        let model = res.model.split(" ")
        let is_ipX = false
        if (model[0] == "iPhone") {
            let type = model[1]
            is_ipX = type < 9 || type == "6/7/8" ? false : true
        }
        this.is_ipX = is_ipX
        this.bottom_height = is_ipX?"margin-bottom:22px":""
        return is_ipX
    },
    // is_ipX: this.$is_X(),
    $get_data(e){
        return e.currentTarget.dataset
    },
    $go(link) {
        console.log(link);
        if (link) {
            uni.navigateTo({
                url: link,
                success: (res) => {
                    console.log(res);
                },
                fail: (err) => {
                    console.log(err);
                }
            });
        } else {
            let url = "http://localhost:8080/"
            let openid = uni.getStorageSync('openid')
            this.copy(url + "?" + openid)
        }

    },
    $copy(data) {
        const res = new Promise((success, fail) =>{
            uni.setClipboardData({
                data,
                success:success,
                fail:fail
            });

        })
        return res;
        
    },
    $get_copy(){
        const res = new Promise((success, fail) => {
            uni.getClipboardData({
                success: success,
                fail:fail
            });
        });
        return res;
    }
}